<?php

/**
 * Description of Utils
 *
 * @author Cristian
 */
class Utils {

    /**
     * The function is_date() validates the date and returns true or false
     * @param $str sting expected valid date format
     * @return bool returns true if the supplied parameter is a valid date
     * otherwise false
     */
    public static function is_date($str) {
        try {
            $dt = new DateTime(trim($str));
        } catch (Exception $e) {
            return false;
        }
        $month = $dt->format('m');
        $day = $dt->format('d');
        $year = $dt->format('Y');
        if (checkdate($month, $day, $year)) {
            return true;
        } else {
            return false;
        }
    }

}

?>
